<template>
  <div>
    <a-row>
      <a-col :span="24">
        <div class="table-container">
          <!-- 查询区域 -->
          <div class="table-page-search-wrapper">
            <!-- 搜索区域 -->
            <a-form-model layout="inline" v-bind="searchModelConfig"
              @keyup.enter.native="searchQuery">
              <a-row v-bind="searchRowConfig">
                <a-col :span="5">
                  <a-form-model-item>
                    <a-input v-model="queryParam.cardName" placeholder="请输入会员卡名称">
                      <a-icon slot="prefix" class="font-placeholder" type="search" />
                    </a-input>
                  </a-form-model-item>
                </a-col>
                <a-col class="table-page-search-submitButtons" v-bind="searchColConfig">
                  <a-button @click="searchQuery" type="primary">查询</a-button>
                  <a-button @click="searchReset" type="danger">重置</a-button>
                </a-col>
              </a-row>
            </a-form-model>
          </div>

          <!-- 操作按钮区域 -->
          <div class="table-operator">
            <div>
              <a-button @click="handleAdd" type="primary" v-has="['insertMember']">新增会员卡</a-button>
            </div>
          </div>
          <!-- table区域-begin -->
          <a-row>
            <a-col :span="24">
              <ry-table
                :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
                :columns="columns" :loading="loading" :data-source="dataSource"
                :rowKey="record=>record.id" :pagination="ipagination" bordered
                :scroll="{ x: 'max-content'}">
                <template slot="limitedQuantity" slot-scope="{text}">
                  {{text + '张'}}
                </template>
                <template slot="totalPrice" slot-scope="{text}">
                  {{text + '万'}}
                </template>
                <template slot="activityPrice" slot-scope="{text}">
                  {{text + '万'}}
                </template>
                <template slot="action" slot-scope="{record}">
                    <a-tooltip title="客户详情">
                      <a-button @click="handleEdit(record)" type="primary" v-has="['memberEdit']">会员卡编辑</a-button>
                    </a-tooltip>
                </template>
              </ry-table>
            </a-col>
          </a-row>
        </div>
        <MemberCardModel ref="modalForm" @ok="modalFormOk" :url="url"></MemberCardModel>
      </a-col>
    </a-row>
  </div>
</template>

<script>
import { RyListMixin } from '@/ryweb'
import MemberCardModel from "./modules/MemberCardModel.vue";
export default {
  name: '',
  mixins: [RyListMixin],
  components: { MemberCardModel },
  data () {
    return {
      reloadDict: true,
      show: false,
      isShow: false,
      phoneData: false,
      education: false,
      maritalStatus: false,
      addressCondition: false,
      address: false,
      columns: [
        {
          title: '会员卡名称',
          align: 'center',
          dataIndex: 'cardName'
        },
        {
          title: '限制数量',
          align: 'center',
          dataIndex: 'limitedQuantity',
          scopedSlots: {customRender: 'limitedQuantity'}
        },
        {
          title: '产品总价值',
          align: 'center',
          dataIndex: 'totalPrice',
          scopedSlots: {customRender: 'totalPrice'}
        },
        {
          title: '会员活动价',
          align: 'center',
          dataIndex: 'activityPrice',
          scopedSlots: {customRender: 'activityPrice'}
        },
        {
          title: '创建时间',
          align: 'center',
          dataIndex: 'createTime'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: this.$api.permission.memberCard.memberCard,
        add: this.$api.permission.memberCard.insert,
        edit: this.$api.permission.memberCard.update
      }
    }
  },
  props: {
    treeId: {
      type: String
    }
  },
  computed: {
  },
  watch: {
    treeId: {
      handler (newVal, oldVal) {
        this.queryParam.idNum = newVal
        this.searchQuery()
      },
      immediate: true
    }
  },
  methods: {
    modalFormOk () {
      // 新增/修改 成功时，重载列表
      this.loadData(1)
    },
    onChange (v) {
      console.log(v)
      v = v.toString()
      console.log('当前的', v)
    },
    // 删除指定项
    arrDel (arr, func) {
      arr.forEach((item, i) => {
        if (func(item)) {
          arr.splice(i, 1)
        }
      })
    }
  },
  filters: {},
  created () {
  },
  mounted () {
  },
  beforeDestroy () { }
}
</script>

<style lang="less">
#LabelInfoMaintain {
  border-left: 1px solid #f4f4f4;
}
.table-operator {
  display: flex;
  justify-content: space-between;
  align-content: center;
  .setting {
    margin-top: 5px;
    font-size: 16px;
    color: #00bbbb;
  }
}
.age_box {
  width: 100%;
  padding: 0;
  .ant-form-item {
    width: 100%;
    text-align: center;
  }
  .ant-input {
    width: 40%;
  }
}
.ant-col .ant-col-1 {
  padding: -12px;
}
.table-page-search-wrapper {
  margin-left: 0rem;
}
</style>
